fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, pkg: &Package,
target: &Target, kind: Kind) {
+ fn opt(cmd: &mut CommandPrototype, key: &str, prefix: &str,
+ val: Option<&str>) {
+ if let Some(val) = val {
+ cmd.arg(key).arg(&format!("{}{}", prefix, val));
+ }
+ }
+
cmd.arg("--out-dir").arg(&cx.out_dir(pkg, kind, target));
cmd.arg("--emit=dep-info,link");
if kind == Kind::Target {
- fn opt(cmd: &mut CommandPrototype, key: &str, prefix: &str,
- val: Option<&str>) {
- if let Some(val) = val {
- cmd.arg(key).arg(&format!("{}{}", prefix, val));
- }
- }
-
opt(cmd, "--target", "", cx.requested_target());
- opt(cmd, "-C", "ar=", cx.ar(kind));
- opt(cmd, "-C", "linker=", cx.linker(kind));
}
+
+ opt(cmd, "-C", "ar=", cx.ar(kind));
+ opt(cmd, "-C", "linker=", cx.linker(kind));
}
fn build_deps_args(cmd: &mut CommandPrototype,
use std::env;
use support::{project, execs};
+use support::{COMPILING, RUNNING};
use hamcrest::assert_that;
fn setup() {
assert_that(p.cargo_process("test").arg("-v"),
execs().with_status(0));
});
+
+// See #1515
+test!(native_plugin_dependency_with_custom_ar_linker {
+ let (_, target) = ::cargo::ops::rustc_version().unwrap();
+
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [lib]
+ name = "foo"
+ plugin = true
+ "#)
+ .file("src/lib.rs", "");
+
+ let bar = project("bar")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+
+ [lib]
+ name = "bar"
+
+ [dependencies.foo]
+ path = "../foo"
+ "#)
+ .file("src/lib", "")
+ .file(".cargo/config", &format!(r#"
+ [target.{}]
+ ar = "ar"
+ linker = "cc"
+ "#, target));
+
+ foo.build();
+ assert_that(bar.cargo_process("build").arg("--verbose"),
+ execs().with_stdout(&format!("\
+{compiling} foo v0.0.1 ({url})
+{running} `rustc [..] -C ar=ar -C linker=cc [..]`
+{compiling} bar v0.0.1 ({url})
+{running} `rustc [..] -C ar=ar -C linker=cc [..]`
+", compiling = COMPILING, running = RUNNING, url = bar.url())))
+});